<?php

/** @package codymvc */

/**
 * @class FrontController
 * @brief Determines what Command to run, and runs it.  This returns the name of 
 * the template to use.  The FrontController then uses the View to display this 
 * template.
 */

class FrontController {

	static function execute() {
        $command = call_user_func(
            array(
                CodyMVC::get_config('commandfactory_class'),
                'create'
            ), 
            $_SERVER['REQUEST_URI']
        );
		$template = $command->execute();
        // void return - action has done something eg. header redirect.
		if ( $template === null ) {
		    return;
		}
        $view_class = CodyMVC::get_config('view_class');
        call_user_func(
            array(
                $view_class,
                'display'
            ),
            $template
        );
	}

}

?>
